import lib.memoize

STATE_FULL = '3'
STATE_INIT = '0'
NEXT_STATE = {'0':'1', '1':'2', '2':'3'}



@lib.memoize.All
def invest(size, digit):
    result = 0

    # all digit are processed
    if digit == 9:
        if size > 3: return 0
        return 1

    # Case where digit is not used
    result += invest(size, digit + 1)

    # Case where digit is used once
    result += invest(size - 1, digit + 1) * size

    # Case where digit is used twice
    result += invest(size - 2, digit + 1) * size * (size-1) / 2

    # Case where digit is used 3 time
    result += invest(size - 3, digit + 1) * size * (size-1) * (size-2)/ (2*3)

    return result


def Solve():
    size = 18

    result = invest(size, 0)
    result -= result / 10
    print result

    return result


if __name__ == "__main__":
    print Solve()

